#ifndef METAL_H
#define METAL_H
#include<utils.h>
#include<material.h>
class metal:public material
{
public:
    metal(const QVector3D&a,float f):albedo(a){
        if(f<1)
        {
            fuzz=f;
        }
        else
        {
            fuzz=1;
        }
    }
    QVector3D albedo;
    virtual bool scatter(const ray&r_in,const hit_record &rec,QVector3D&attenuation,ray&scattered)const{
        QVector3D reflected=reflect(r_in.direction().normalized(),rec.normal);
        scattered=ray(rec.p,reflected+fuzz*random_in_unit_sphere(),r_in.time());
        attenuation=albedo;
        return (QVector3D::dotProduct(scattered.direction(),rec.normal)>0);

    }
    float fuzz;
};

#endif // METAL_H
